package com.hotel.interceptor;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;

import com.hotel.context.BaseContext;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;


/**
 * @author zxq
 */
@Component
public class MyMetaObjectHandler  implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject,"createTime", Date.class, new Date());
        this.strictInsertFill(metaObject,"createBy", Long.class, BaseContext.getCurrentId());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
    this.strictUpdateFill(metaObject,"updateTime", Date.class, new Date());
    this.strictUpdateFill(metaObject,"updateBy", Long.class, BaseContext.getCurrentId());
    }
}
